/*
 * Copyright (C) 2018 www.missfresh.cn All rights reserved.
 *
 * Created by wangzheng@missfresh.cn on 2019-01-16.
 */


package com.dylan.历史.util.mryx;

import org.apache.commons.lang3.ArrayUtils;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERInteger;
import org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemWriter;

import javax.crypto.Cipher;
import java.io.StringWriter;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.X509EncodedKeySpec;

/**
 * @author wangzheng@missfresh.cn on 2019-01-16
 */
@SuppressWarnings("all")
public class RSAUtil {
    @SuppressWarnings("all")
    private static String pkcs1PrivateKey = "MIICXgIBAAKBgQCo7NRRFozT54HcSI3sSkV68gJuv1Wsn86mU8aorxRRa6ZFBAja\n" +
            "EbiHl2XbqpndQz6mAwhDgZjZY9eujn3P/7ozv6NttyUwuN6OiOCDTceqqz07nEaV\n" +
            "cDlEgU2CECXBVybjS2nQj5s3OS9frSCjpSOb9XmweUI+SUMjzHGtGmN7FQIDAQAB\n" +
            "AoGAB9AENcfcNYS0fdKhNbdtpTUCJcsVlElDzm97dZu7TdSzuOdp3WQKa8L1xAYM\n" +
            "3a3ZfOYRAMZConM6q2kNqowCOYU5LpDVUOLzx4loSvrNwoncWksV1phv+8OD3QgF\n" +
            "7vILaN99hQvQ3Ht7vqTnNcP2Ff71UMXuySTSmrHUxX8cwBUCQQDXUaMeul2PeaE4\n" +
            "xwMCVptarCV87HLditaiIWtLzme054xgcobWPrRPWzyjXz4EpiWncLvlIA0NdFfT\n" +
            "9cYhftkDAkEAyNdBxJmjwbRyk23YNcHcFEVlkBiJQPWHKvcAZPz63vHPyhPf83pi\n" +
            "ns75WCWt/sK5MaFCrwd/Dg0rX9MJsgKEBwJBALFxtMUo/tuzd9rrnx45M3RI8+f8\n" +
            "kDjlJzab5emmIy8htzzwhRBgwoW3gcR9RAXeyp8vt5j+jeMtowepvutxtvMCQQCe\n" +
            "NcNfRdBUBPvE22DYaBAf/9LTwiBNBZ0m4VB0PTy6Zy5Sd3mRaTVK+Kw/Hd+EsowE\n" +
            "Zo4LJxKVVRZ389zNV2H9AkEAjf4Q/pne3EvE2LJyqAtNi0dmCcoT94bGP3Y9clFz\n" +
            "of0t2KS6e+w67VLScnL45erZQqXIs2HEbbtHbh3tivsETw==";
    @SuppressWarnings("all")
    private static String pkcs8PrivateKey = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAKjs1FEWjNPngdxI\n" +
            "jexKRXryAm6/VayfzqZTxqivFFFrpkUECNoRuIeXZduqmd1DPqYDCEOBmNlj166O\n" +
            "fc//ujO/o223JTC43o6I4INNx6qrPTucRpVwOUSBTYIQJcFXJuNLadCPmzc5L1+t\n" +
            "IKOlI5v1ebB5Qj5JQyPMca0aY3sVAgMBAAECgYAH0AQ1x9w1hLR90qE1t22lNQIl\n" +
            "yxWUSUPOb3t1m7tN1LO452ndZAprwvXEBgzdrdl85hEAxkKiczqraQ2qjAI5hTku\n" +
            "kNVQ4vPHiWhK+s3CidxaSxXWmG/7w4PdCAXu8gto332FC9Dce3u+pOc1w/YV/vVQ\n" +
            "xe7JJNKasdTFfxzAFQJBANdRox66XY95oTjHAwJWm1qsJXzsct2K1qIha0vOZ7Tn\n" +
            "jGByhtY+tE9bPKNfPgSmJadwu+UgDQ10V9P1xiF+2QMCQQDI10HEmaPBtHKTbdg1\n" +
            "wdwURWWQGIlA9Ycq9wBk/Pre8c/KE9/zemKezvlYJa3+wrkxoUKvB38ODStf0wmy\n" +
            "AoQHAkEAsXG0xSj+27N32uufHjkzdEjz5/yQOOUnNpvl6aYjLyG3PPCFEGDChbeB\n" +
            "xH1EBd7Kny+3mP6N4y2jB6m+63G28wJBAJ41w19F0FQE+8TbYNhoEB//0tPCIE0F\n" +
            "nSbhUHQ9PLpnLlJ3eZFpNUr4rD8d34SyjARmjgsnEpVVFnfz3M1XYf0CQQCN/hD+\n" +
            "md7cS8TYsnKoC02LR2YJyhP3hsY/dj1yUXOh/S3YpLp77DrtUtJycvjl6tlCpciz\n" +
            "YcRtu0duHe2K+wRP";

    @SuppressWarnings("all")
    private static String pkcs1Public = "MIGJAoGBAKjs1FEWjNPngdxIjexKRXryAm6/VayfzqZTxqivFFFrpkUECNoRuIeX\n" +
            "Zduqmd1DPqYDCEOBmNlj166Ofc//ujO/o223JTC43o6I4INNx6qrPTucRpVwOUSB\n" +
            "TYIQJcFXJuNLadCPmzc5L1+tIKOlI5v1ebB5Qj5JQyPMca0aY3sVAgMBAAE=\n";

    @SuppressWarnings("all")
    private static String pkcs8Public = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCo7NRRFozT54HcSI3sSkV68gJu\n" +
            "v1Wsn86mU8aorxRRa6ZFBAjaEbiHl2XbqpndQz6mAwhDgZjZY9eujn3P/7ozv6Nt\n" +
            "tyUwuN6OiOCDTceqqz07nEaVcDlEgU2CECXBVybjS2nQj5s3OS9frSCjpSOb9Xmw\n" +
            "eUI+SUMjzHGtGmN7FQIDAQAB";

    //生成秘钥对
    private static KeyPair getKeyPair() throws Exception {
        KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
        keyPairGenerator.initialize(2048);
        KeyPair keyPair = keyPairGenerator.generateKeyPair();
        return keyPair;
    }

    //获取公钥(Base64编码)
    private static String getPublicKey(KeyPair keyPair) {
        PublicKey publicKey = keyPair.getPublic();
        byte[] bytes = publicKey.getEncoded();
        return Base64Utils.byte2Base64(bytes);
    }

    //获取私钥(Base64编码)
    private static String getPrivateKey(KeyPair keyPair) {
        PrivateKey privateKey = keyPair.getPrivate();
        byte[] bytes = privateKey.getEncoded();
        return Base64Utils.byte2Base64(bytes);
    }

    //将Base64编码后的公钥转换成PublicKey对象
    private static PublicKey string2PublicKey(String pubStr) throws Exception {
        byte[] keyBytes = Base64Utils.base642Byte(pubStr);
        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        PublicKey publicKey = keyFactory.generatePublic(keySpec);
        return publicKey;
    }

    //将Base64编码后的私钥转换成PrivateKey对象
    private static PrivateKey string2PrivateKey(String priStr) throws Exception {
        byte[] keyBytes = Base64Utils.base642Byte(priStr);
        PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        PrivateKey privateKey = keyFactory.generatePrivate(keySpec);
        return privateKey;
    }

    //公钥加密
    private static byte[] publicEncrypt(byte[] content, PublicKey publicKey) throws Exception {
        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.ENCRYPT_MODE, publicKey);

        // 加密时超过117字节就报错。为此采用分段加密的办法来加密
        StringBuilder sb = new StringBuilder();
        byte[] dataReturn = null;
        for (int i = 0; i < content.length; i += 100) {
            byte[] doFinal = cipher.doFinal(ArrayUtils.subarray(content, i,
                    i + 100));
            sb.append(new String(doFinal));
            dataReturn = ArrayUtils.addAll(dataReturn, doFinal);
        }
        return dataReturn;
    }

    //私钥解密
    private static String privateDecrypt(byte[] content, PrivateKey privateKey) throws Exception {
        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.DECRYPT_MODE, privateKey);

        // 解密时超过128字节就报错。为此采用分段解密的办法来解密
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < content.length; i += 128) {
            byte[] doFinal = cipher.doFinal(ArrayUtils.subarray(content, i,
                    i + 128));
            sb.append(new String(doFinal));
        }
        return sb.toString();
    }

    public static String encryptAndBase64(String content) throws Exception {
        PublicKey publicKey = string2PublicKey(RSAUtil.pkcs8Public);
        byte[] en = publicEncrypt(content.getBytes(), publicKey);
        return Base64Utils.byte2Base64(en);
    }

    public static String decryptFromPKCS1(String enCode) throws Exception {
        byte[] enStringBase64 = Base64Utils.base642Byte(enCode);
        PrivateKey privateKey = RSAUtil.getPrivateKeyFromPkcs1Private(RSAUtil.pkcs1PrivateKey);
        String deContent = RSAUtil.privateDecrypt(enStringBase64, privateKey);
        String unzipedConetent = ZipCompressUtils.gunzip(deContent);
        return unzipedConetent;
    }

    public static String base64AndDecrypt(String enCode) throws Exception {
        byte[] enStringBase64 = Base64Utils.base642Byte(enCode);
        PrivateKey privateKey = RSAUtil.getPrivateKeyFromPkcs1Private(RSAUtil.pkcs1PrivateKey);
        String deContent = RSAUtil.privateDecrypt(enStringBase64, privateKey);
        return deContent;
    }

    public static String decryptFromPKCS8(String enCode) throws Exception {
        return decryptFromPKCS1(enCode);
    }

    private static PrivateKey getPrivateKeyFromPkcs1Private(String pkcs1PrivateKey) {
        try {
            ASN1Object asn1Object = ASN1Sequence.fromByteArray(Base64Utils.base642Byte(pkcs1PrivateKey));
            ASN1Sequence sequence = null;
            if (asn1Object instanceof ASN1Sequence) {
                sequence = (ASN1Sequence) asn1Object;
            }
            DERInteger derInteger = null;

            RSAPrivateKeyStructure asn1PrivKey = RSAPrivateKeyStructure.getInstance(sequence);

            RSAPrivateKeySpec rsaPrivKeySpec
                    = new RSAPrivateKeySpec(asn1PrivKey.getModulus(), asn1PrivKey.getPrivateExponent());
            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
            PrivateKey priKey = keyFactory.generatePrivate(rsaPrivKeySpec);
            return priKey;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static String pkcs8Private2Pkcs1Private(String pkcs8Privatekey) {
        try {

            PrivateKey privateKey = string2PrivateKey(pkcs8Privatekey);
            ASN1Object asn1Object = ASN1Sequence.fromByteArray(privateKey.getEncoded());
            ASN1Sequence sequence = null;
            if (asn1Object instanceof ASN1Sequence) {
                sequence = (ASN1Sequence) asn1Object;
            }
            DERInteger derInteger = null;
            RSAPrivateKeyStructure asn1PrivKey = RSAPrivateKeyStructure.getInstance(sequence);
            RSAPrivateKeySpec rsaPrivKeySpec
                    = new RSAPrivateKeySpec(asn1PrivKey.getModulus(), asn1PrivKey.getPrivateExponent());
            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
            PrivateKey priKey = keyFactory.generatePrivate(rsaPrivKeySpec);

            return Base64Utils.byte2Base64(priKey.getEncoded());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

//    public static String pkcs8Private2Pkcs1Private(String pkcs8Privatekey) {
//        try {
//            PrivateKey privateKey = string2PrivateKey(pkcs8Privatekey);
//            byte[] privBytes = privateKey.getEncoded();
//
//            PrivateKeyInfo pkInfo = PrivateKeyInfo.getInstance(privBytes);
//            ASN1Encodable encodable = pkInfo.parsePrivateKey();
//            ASN1Primitive primitive = encodable.toASN1Primitive();
//            byte[] privateKeyPKCS1 = primitive.getEncoded();
//            return pkcs1ToPem(privateKeyPKCS1, false);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return null;
//    }

    public static String pkcs1ToPem(byte[] pcks1KeyBytes, boolean isPublic) throws Exception {
        String type;
        if (isPublic) {
            type = "RSA PUBLIC KEY";
        } else {
            type = "RSA PRIVATE KEY";
        }

        PemObject pemObject = new PemObject(type, pcks1KeyBytes);
        StringWriter stringWriter = new StringWriter();
        PemWriter pemWriter = new PemWriter(stringWriter);
        pemWriter.writeObject(pemObject);
        pemWriter.close();
        String pemString = stringWriter.toString();

        return pemString;
    }

    /**
     * .
     *
     * @param args ""
     */
    public static void main(String[] args) {
        try {
            String content = "这仅仅是个测试";
//            PublicKey publicKey = string2PublicKey(RSAUtil.pkcs1Public);
//            byte[] enContent = RSAUtil.publicEncrypt(content.getBytes(), publicKey);
//            System.out.println(enContent);
//
//            PrivateKey privateKey = string2PrivateKey(RSAUtil.pkcs1PrivateKey);
//            byte[] deContent = RSAUtil.privateDecrypt(enContent, privateKey);
//            System.out.println(deContent);

//            KeyPair keyPair = getKeyPair();
//            System.out.println(getPrivateKey(keyPair));

//            PublicKey publicKey = string2PublicKey(RSAUtil.pkcs8Public);
//            byte[] enContent = RSAUtil.publicEncrypt(content.getBytes(), publicKey);
//            PrivateKey privateKey = string2PrivateKey(RSAUtil.pkcs8PrivateKey);
//            byte[] deContent = RSAUtil.privateDecrypt(enContent, privateKey);
//            System.out.println(new String(deContent));


//            PublicKey publicKey = string2PublicKey(RSAUtil.pkcs8Public);
//            byte[] enContent = RSAUtil.publicEncrypt(content.getBytes(), publicKey);
//            PrivateKey privateKey = RSAUtil.pkcs1Private2Pkcs8Private(RSAUtil.pkcs1PrivateKey);
//            byte[] deContent = RSAUtil.privateDecrypt(enContent, privateKey);
//            System.out.println(new String(deContent));


            String content1 = "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试" +
                    "这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试,这仅仅是个测试11";

//            System.out.println(content1.length());
//            String ziped  = ZipCompressUtils.zip(content1);
//            System.out.println(ziped.length());
//            System.out.println(ZipCompressUtils.unzip(ziped));

            content1 = "test";
            String ziped = ZipCompressUtils.zip(content);
            PublicKey publicKey = string2PublicKey(RSAUtil.pkcs8Public);
            byte[] enContent = RSAUtil.publicEncrypt(ziped.getBytes(), publicKey);
            String enString = Base64Utils.byte2Base64(enContent);



//            byte[] enStringBase64 = Base64Utils.base642Byte(enCode);
//            PrivateKey privateKey = RSAUtil.getPrivateKeyFromPkcs1Private(RSAUtil.pkcs8PrivateKey);
//            String deContent = RSAUtil.privateDecrypt(enStringBase64, privateKey);
//            return ZipCompressUtils.unzip(deContent);


            enString = "Ey5XoPBleOPETuwRdZeqWf7xAW2NBLqab5o1sMzY7ozujdAZ8ZmvAUXdNd0Gpj6bOV5dnD5uT0me\n" +
                    "rJUXU4w3VNxYZM/ewIpKCXyhfdj1RR7gId+neih3tR6DG1xnBOk0YZpEAbiOX33mqgOoiZdSQps9\n" +
                    "7j+HNskYBdMXnAt1GYg=";
            System.out.println(RSAUtil.decryptFromPKCS8(enString));
//            byte[] enStringBase64 = Base64Utils.base642Byte(enString);
//            PrivateKey privateKey = RSAUtil.getPrivateKeyFromPkcs1Private(RSAUtil.pkcs1PrivateKey);
//            String deContent = RSAUtil.privateDecrypt(enStringBase64, privateKey);
//            String unzipedConetent = ZipCompressUtils.unzip(deContent);
//            System.out.println(unzipedConetent);

//            byte[] enContent2 = RSAUtil.publicEncrypt(content1.getBytes(), publicKey);
//            String ziped2 = ZipCompressUtils.zip(RSAUtil.byte2Base64(enContent2));
//            System.out.println(ziped2.length());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
